package com.tang.hawkmusic.fragment;

import android.content.Context;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tang.hawkmusic.R;
import com.tang.hawkmusic.activity.local.LocalActivity;
import com.tang.hawkmusic.adapter.LocalMusicAdapter;
import com.tang.hawkmusic.bean.music.LocalMusic;

import java.util.ArrayList;


public class LocalMusicFragment extends Fragment {
    Context context;
    RecyclerView recyclerView;
    ArrayList<LocalMusic> musics;
    public LocalMusicFragment() {
        // Required empty public constructor
    }

    public LocalMusicFragment(Context context) {
        this.context = context;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_local_music, container, false);
        recyclerView=view.findViewById(R.id.music_list_recyclerView);
        initMusicListView();
        return view;
    }

    public void initMusicListView(){
        Log.d("TAG", "initMusicListView: "+musics.size());
        LocalMusicAdapter adapter=new LocalMusicAdapter(musics,getActivity());
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(getContext());
        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(linearLayoutManager);


    }

    public void setMusics(ArrayList<LocalMusic> musics) {
        this.musics = musics;
    }
}